<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form:form action="processAdd" method="post" modelAttribute="category">
			<spring:hasBindErrors name="category">
				<div class="response-msg error ui-corner-all">
					<spring:bind path="category">
						<c:forEach items="${status.errors.globalErrors}" var="error">
							<span><spring:message code="${error.code}"></spring:message></span>
						</c:forEach>
					</spring:bind>
					<spring:bind path="category.*">
						<c:forEach items="${status.errors.fieldErrors}" var="error">
							<spring:message code="${error.code}" ></spring:message><br>
						</c:forEach>
					</spring:bind>
				</div>
			</spring:hasBindErrors>
		<table>
			<tr>
				<td>Category name</td>
				<td><form:input path="name" /> </td>
			</tr>
			<tr>
				<td>Description</td>
				<td><form:textarea path="description"/> </td>
			</tr>
			<tr>
				<td>Parent category:</td>
				<td>
					<form:select path="parent">
						<form:option value=""></form:option>
						<form:options itemLabel="name" itemValue="id" items="${categories}"/>	
					</form:select>
				</td>
			</tr> 
			<tr>
				<td colspan="2"><input type="submit" value="Submit" class="submit" /></td>
			</tr>
		</table>
	</form:form>

</body>
</html>